<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2003 XBRL International. All Rights Reserved. -->
<?xml-stylesheet type="text/xsl" href="../../testcase.xsl"?>
<testcase name="SummationItem" 
  description="5.2.5.2 - Fully conformant XBRL processors MUST detect and signal inconsistencies, as defined above, between an XBRL instance and the summation-item arcs of calculation linkbases in its supporting DTS" 
  outpath="out" 
  owner="mrg@decisionsoft.com" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:noNamespaceSchemaLocation="../lib/test.xsd" 
  minimal="false">

  <!-- NOTE: The conformance suite does not distinguish between 'invalid' and
  'inconsistent'.  The variations in this testcase that are marked as 'invalid'
  are in fact valid XBRL, they just contain summation-item inconsistencies. -->


  <variation id="V-00" name="ConsistentInstance">
    <description>A simple consistent instance; A = B + C</description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-00-ConsistentInstance-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-01" name="InconsistentInstance">
    <description>A simple inconsistent instance; A != B + C</description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-01-InconsistentInstance-invalid.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>


  <variation id="V-02" name="NonCEqualContributing">
    <description>

      A != B + C, but A is in a different context from B and C, so B and C are
      not contributing items for A.  No checks are performed.  The instance is
      consistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-02-NonCEqualContributing-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-03" name="NonUEqualContributing">
    <description>

      A != B + C, but A has a different unit from B and C, so B and C are not
      contributing items for A.  No checks are performed.  The instance is
      consistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-03-NonUEqualContributing-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-04" name="SEqualContextsAndUnitsContributing">
    <description>

      B and C are c-equal and u-equal to A.  B and C are contributing items for
      A, but A != B + C so the instance is inconsistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-04-SEqualContextsAndUnitsContributing-invalid.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>


  <variation id="V-05" name="BothNilContributing">
    <description>

      B and C are both nil-valued, so neither contributes to A.  No checks are
      performed.  The instance is consistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-05-BothNilContributing-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-06" name="OneNilContributingConsistent">
    <description>

      B is nil-valued but C is not.  A = C, so the instance is consistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-06-OneNilContributing-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-07" name="OneNilContributingInconsistent">
    <description>

      B is nil-valued but C is not.  A != C, so the instance is not consistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-07-OneNilContributing-invalid.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>


  <variation id="V-08" name="OneContributingConsistent">
    <description>A simple consistent instance; A = B; C not present</description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-08-OneContributing-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-09" name="OneContributingInconsistent">
    <description>A simple inconsistent instance; A != B; C not present</description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-09-OneContributing-invalid.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>

  
  <variation id="V-10" name="NilSummationItem">
    <description>

      A (the summation item) is nil, so no checks are performed. 

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-10-NilSummationItem-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-11" name="DuplicateSummationItems">
    <description>

      Two occurrences of A, the first of which is nil.  The first is ignored.
      The second would result in an inconsistency were it not for the fact that
      it is a duplicate of the first (because values are not considered).

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-11-DuplicateSummationItems-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-12" name="DuplicateContributingItems">
    <description>

      Things don't add up, but this goes undetected because one of the
      contributing items is duplicated.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-12-DuplicateContributingItems-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-13" name="InconsistentWithinTuple">
    <description>

      All items within one tuple, and things don't add up.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-Holder.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-13-InconsistentWithinTuple-invalid.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>


  <variation id="V-14" name="SeparateTuplesConsistent">
    <description>

      Summation item is in a separate tuple from occurrences of the
      contributing concepts.  Because of tuple scoping rules, the summation
      item has no contributing items.  Nothing is checked.  The instance is
      consistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-Holder.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-14-SeparateTuplesConsistent-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-15" name="ContributingWithinTuples">
    <description>

      Contributing items (within tuples) are in-scope for the summation item
      (at top level).  Inconsistency should be detected.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-Holder.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-15-ContributingWithinTuples-invalid.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>


  <variation id="V-16" name="MultiLevelBinding">
    <description>

      Summation item at top level has sibling contributing items and nephew
      contributing items.  Inconsistency should be detected.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-Holder.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-16-MultiLevelBinding-invalid.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>

  <variation id="V-17" name="ConsistentCountdown">
    <description>

      Binding across many levels (consistent).

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-Holder.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-17-ConsistentCountdown-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>


  <variation id="V-18" name="InconsistentCountdown">
    <description>

      Binding across many levels (inconsistent).

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-Holder.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-18-InconsistentCountdown-invalid.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>


  <variation id="V-19" name="DuplicateCountdown">
    <description>

      Would be inconsistent, were it not for the duplicate contributing items
      deep in the hierarchy.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-Holder.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-19-DuplicateCountdown-valid.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>

  <variation id="V-20" name="NoSummationItemInference">
    <description>

      If you infer a value for 'A', then X is consistent, but since this is not
      allowed, the instance is inconsistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-XYZ.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <linkbase readMeFirst="false">397-XYZ-calculation.xml</linkbase>
      <instance readMeFirst="true">397-20-NoSummationItemInference-invalid.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>

  <variation id="V-21" name="NoEssenceAliasInference">
    <description>

      If you infer a value for 'A', then X is consistent, but since this is not
      allowed, the instance is inconsistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-XYZ.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <linkbase readMeFirst="false">397-XYZ-calculation.xml</linkbase>
      <linkbase readMeFirst="false">397-XYZ-definition.xml</linkbase>
      <instance readMeFirst="true">397-21-NoEssenceAliasInference-invalid.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>

  <variation id="V-22" name="TopAndTupleInconsistent">
    <description>

    The 'B' and 'C' children both inside and outside the tuple are, according to the spec, bound in the summation of 'A' at the top level.
    10 + 20 + 1 + 2 is not equal to 3.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-XYZ.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <linkbase readMeFirst="false">397-XYZ-calculation.xml</linkbase>
      <linkbase readMeFirst="false">397-XYZ-definition.xml</linkbase>
      <instance readMeFirst="true">397-22-TopAndTuple-inconsistent.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>
  
  <variation id="V-23" name="TopAndTupleConsistent">
    <description>

    The 'B' children both inside and outside the tuple are, according to the spec, bound in the summation of 'A' at the top level.
    20 + 2 equals 22.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <xsd readMeFirst="false">397-XYZ.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <linkbase readMeFirst="false">397-XYZ-calculation.xml</linkbase>
      <linkbase readMeFirst="false">397-XYZ-definition.xml</linkbase>
      <instance readMeFirst="true">397-23-TopAndTuple-consistent.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>
  
  
  <variation id="V-24" name="PrecisionZeroRoundUp">
    <description>

    Value of A = 0.8 to precision zero is inconsistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-24-PrecisionZeroRoundUp.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>
  
  <variation id="V-25" name="PrecisionZeroRoundDown">
    <description>

    Value of A = 0.4 to precision zero is inconsistent.

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-25-PrecisionZeroRoundDown.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>
  
  
  <variation id="V-26" name="DecimalsTrailingDigitsValid">
    <description>
    Valid with decimals summation because 0.5 (precision=INF) + -0.5 (precision=INF) = 0.08 (decimals=0).  Valid, since 0.08 to 0 decimal places becomes 0, which agrees with the calculated total. 
    (In prior approach based on inferred precision, if stated decimals is less than the actual precision, you get precision 0 which is inconsistent.)

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-26-DecimalsTrailingDigits.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>
  
  <variation id="V-27" name="DecimalsTrailingDigitsInvalid">
    <description>
     Invalid with decimals summation because 0.5 (precision=INF) + -0.5 (precision=INF) != 0.8 (decimals=0).  It's invalid because the total gets rounded up to 1 which disagrees with the calculated total of 0.
    (In prior approach based on inferred precision, if stated decimals is less than the actual precision, you should get precision zero which is inconsistent.)

    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-27-DecimalsTrailingDigits.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>
  
  <variation id="V-28" name="PrecisionDifferentScales">
    <description>
    In the current inferring decimals approach, the summation item reported as 100.00 precision 5, is deemed 100.00 decimals 2,
    and compared to a sum of contributing items 99.996, with 99.996 rounded according to the precision of the summation item, which
    is deemed decimals 2, so then the sum of contributing items after such rounding is 100.00, exactly matching the summation item, and
    this case is valid.
    (In the prior approach with inferred precision, this was invalid because
    the summation item is 100.00 precision 5 and the calculated total of contributing items is 99.996, which when rounded to precision 5, remains
    99.996.
    This is within the implied error bounds so you might reasonably expect the calculation to be consistent.
    The prior spec which required inferring precision, however, says to round using the precision of the total so you actually end up checking 100 against 99.996 so that the calculation fails.)
    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-28-PrecisionDifferentScales.xbrl</instance>
    </data>
    <result expected="valid"/>
  </variation>
  
  <variation id="V-29" name="StatedPrecisionZeroContribution">
    <description>
    The contribution items have stated precision 0.
    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-29-StatedPrecisionZeroContributions.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>
  
  <variation id="V-30" name="InferredPrecisionZeroContribution">
    <description>
    Invalid with decimals approach because 0.5 (decimals=0) + 0.5 (decimals=0) != 1 (precision=INF).  It's still invalid because each 0.5 gets rounded up to 1, giving a calculated total of 2. 
    (In prior approach based on inferring precision, invalid because the contribution items have inferred precision 0.)
    </description>
    <data>
      <xsd readMeFirst="false">397-ABC.xsd</xsd>
      <linkbase readMeFirst="false">397-ABC-calculation.xml</linkbase>
      <instance readMeFirst="true">397-30-InferredPrecisionZeroContributions.xbrl</instance>
    </data>
    <result expected="invalid"/>
  </variation>
  
</testcase>
